#ifndef _WIND_MGR_H_
#define _WIND_MGR_H_

#include <widget/cdwindow.h>
#include "page_base.h"
#include "page_pop.h"

#define d_windMgr WindMgr::ins()

class WindMgr : public MessageHandler
{
#define USE_DELAY_RECLCYER 1

private:
    Window *mWindow;
    ViewGroup *mWindLayout;

    ViewGroup *mWindPageBox;
    ViewGroup *mWindPopBox; // 弹窗Box
    PageBase *mShowPage;

    Message mPageCloseMesg;                 // 关闭页面消息
    std::vector<PageBase *> mClosePageList; // 需要回收的窗口列表
    PagePop *mPopPage;                      // 当前显示的弹窗页面

public:
    void initWindow();
    void showPage(pageType type, bool isNewPage = true, int mode = 1, int position = -1);
    void showPopPage(int type, pop_callback enterCb, pop_callback cencelC, int position);
    void dealClosePopPage();
    void sendMsg(int page, int type, void *data);
    static WindMgr *ins()
    {
        static WindMgr ins;
        return &ins;
    };
    void handleMessage(Message &message) override;
    ViewGroup *getMWindPopBox() { return mWindPopBox; };

protected:
    WindMgr() {};
    enum
    {
        MSG_PAGE_DELAY_CLOSE, // 延迟关闭页面
    };
};

#endif